package board.model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import common.db.DBClose;
import common.db.DBConnection;

public class BoardDao {
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	ResultSet rs = null;
	
	public List list(){
		BoardVo boardVo = null;
		List list = new ArrayList();
		
		try {
			
			conn = DBConnection.getInstance().getConnection();
			
//			Class.forName("com.mysql.jdbc.Driver");
//			conn = DriverManager.getConnection("jdbc:mysql://localhost/buytouch", "buytouch", "1234");
			String sql = "select seq, title, content from board where seq = 1";
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			
			while(rs.next()){
				
				boardVo = new BoardVo();
				boardVo.setSeq(rs.getString("seq"));
				boardVo.setTitle(rs.getString("title"));
				boardVo.setContent(rs.getString("content"));
				list.add(boardVo);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}/* catch(ClassNotFoundException e){
			
		}*/finally{
			DBClose.close(rs, pstmt, conn);
		}
		
		return list;
	}

}
